<style>
.fui-list-inner .row .row-text{font-size:0.7rem}
</style>
<div ng-if="pagedata.op!='fa'" class='fui-page fui-page-current'>
    <div class="fui-header">
        <div class="fui-header-left">
            <a class="back" ng-click="goback();"></a>
        </div>
        <div class="title">订单管理</div>
    </div>
    <!-- 顶部tab -->
    <div id="tab" class="fui-tab fui-tab-danger" style="margin-top:2.3rem">
			<a ng-class="{'active':pagedata.params.status==1}" ng-click="pagedata.params.status=1;tool.get_list('jy_weishop/store.manage.order/getlist/',true);">待发货</a>
            <a ng-class="{'active':pagedata.params.status==0}" ng-click="pagedata.params.status=0;tool.get_list('jy_weishop/store.manage.order/getlist/',true);" >待付款</a>
            <a ng-class="{'active':pagedata.params.status==2}" ng-click="pagedata.params.status=2;tool.get_list('jy_weishop/store.manage.order/getlist/',true);">待收货</a>
            <a ng-class="{'active':pagedata.params.status==3}" ng-click="pagedata.params.status=3;tool.get_list('jy_weishop/store.manage.order/getlist/',true);">已完成</a>
            <a ng-class="{'active':pagedata.params.status==4}" ng-click="pagedata.params.status=4;tool.get_list('jy_weishop/store.manage.order/getlist/',true);">已关闭</a>
    </div>
    <div class='fui-content' style="margin-top:0.5rem">
		<div class="searchbar" style='margin:0.3rem;padding:0;margin-bottom:0'>
                    <div class="search-input">
                        <i id="searchsub" class="icon icon-search" ng-click="tool.get_list('jy_weishop/store.manage.order/getlist/',true)"></i>
                        <input type="search" id='keywords' ng-model="pagedata.params.ordersn" placeholder="输入订单号..." style="border-radius:1rem;border: 1px solid #f7f7f7;">
                    </div>
        </div>
        <!-- 订单列表 -->
		<div style="padding:0 0.5rem">
        <div class="fui-list-outer container"></div>
        <div ng-repeat="item in pagedata.list" class="fui-list-group" >
            <a class="fui-list order-list title-b" ng-click="access_json('jy_weishop/store.manage.order_detail//id='+item.id)"  data-nocache="true">
                <div class="fui-list-media">
                    <span ng-if='item.ispay==1' class="fui-label fui-label-danger round">{{pagedata.paytype[item.paytype]}}</span>
					<span ng-if='item.ispay==0' class="fui-label fui-label-danger round">未付款</span>
                </div>
                <div class="fui-list-inner">
                    <div class="row">
                        <div class="row-text" style="font-size: 0.7rem; color: #666">{{item.ordersn}}</div>
                    </div>
                    <div class="row gary">
                        <div class="row-text">{{item.createtime}}</div>
                    </div>
                </div>
                <div class="angle"></div>
            </a>
            
                <div ng-repeat="m in item.merchs">
						<!--<a ng-if="m.id" href="javascript:;" data-nocache="true" ng-click="access_json('jy_weishop/merch//id='+m.id)">
							<div class="fui-list-group-title lineblock bold">
								<i class="icon jinyunicon icon-dianpu"></i> {{m.merchname || '多商户'}}
								<span class="status noremark" style="font-size:0.50rem" ><i class="icon jinyunicon icon-icon-test"></i></span>
							</div>
						</a>
						<a ng-if="!m.id" href="javascript:;" data-nocache="true" ng-click="access_json('jy_weishop/index/')">
							<div class="fui-list-group-title lineblock bold">
								<i class="icon jinyunicon icon-dianpu"></i> {{pagedata.shopset.store_title || '平台自营'}}
								<span class="status noremark" style="font-size:0.50rem" ><i class="icon jinyunicon icon-icon-test"></i></span>
							</div>
						</a>-->
						<a href="javascript:;" ng-repeat="g in m.goods" class="external" data-nocache="true" ng-click="access_json('jy_weishop/store.manage.order_detail//id='+item.id)">
							<div class="fui-list goods-list" style="background:#fff">
								<div class="fui-list-media" style="">
									<img class="" ng-src="{{tomedia(g.image) || '../core/resource/images/nopic.jpg'}}">
								</div>
								<div class="fui-list-inner">
									<div class="text goodstitle towline">{{g.title}}</div>
									<div class="text" style="color:#f60;font-size:0.50rem">{{g.selespename || '无规格'}} x {{g.total || 1}}</div>
									<div class="text"><i class="fui-tag fui-tag-red">{{item.buytypetitle}}</i></div>
								</div>
								<div class="fui-list-angle" style="width:3rem">
									￥<span class="marketprice">{{g.price}}</span></div>
							</div>
						</a>
					</div>
           
            <div class="fui-list log-list noclick">
                <div class="fui-list-inner">
                    <div class="row log-row order">
                        <div class="row-text">订单状态</div>
                        <div class="row-remark"><span class="text-danger">{{item.statustitle}}</span></div>
                    </div>
                    <div class="row log-row order">
                        <div class="row-text">买家昵称</div>
                        <div class="row-remark">{{item.member.nickname}}</div>
                    </div>
					<div class="row log-row order">
                        <div class="row-text">收件人</div>
                        <div class="row-remark">{{item.realname}}</div>
                    </div>
                    <div class="row log-row order">
                        <div class="row-text">配送方式</div>
                        <div class="row-remark"><span class="text-success">{{pagedata.sendtype[item.sendtype]}}</span></div>
                    </div>
                   
                        <div ng-if="item.remark" class="row log-row order">
                            <div class="row-text">买家留言</div>
                            <div class="row-remark">{{item.remark}}</div>
                        </div>
                  
                </div>
            </div>

            <div class="fui-list-group-title text-right">
                <small class="status">共<span class="text-success">{{item.total}}</span>个商品 实付:<span class="text-success">￥{{item.price}}</span> </small>
            </div>
			<div ng-if="item.address" class="fui-list-group-title lineblock" style="line-height:1rem;padding:0 0.5rem">
				<span style="line-height:1.3;color:#999;font-size:0.65rem"><i class="icon icon-ditu"></i> 配送22： <span class="text-danger">{{item.address}}</span>  <a href="javascript:" ng-click="pagedata.openLocation(item.addressinfo);" class="syscolor" style="font-size:0.65rem;line-height: 1.5;"><i class="icon icon-lvyoutehui"></i>导航</a></span>
			</div>
            <div class="fui-list-group-title text-right big weui_cells_checkbox" style="height:auto">
				<div ng-if="item.status==1 && item.send_status==0" class="checkbox-inline l-f" ng-click="duoxuans(item.id,pagedata,'ids')" style="padding-left:1rem;width:4rem;text-align:left;line-height:1.5rem">
					<input type="checkbox" id="id{{item.id}}" name="id{{item.id}}" ng-checked="pagedata.ids.indexOf(';'+item.id+';')>=0" class="fui-radio fui-radio-danger cartmode check-item"/>
					<span style="font-size:0.6rem">合并发货</span>
				</div>
				<a ng-if="item.ispay==0 && item.status<3" ng-click="modal_json({'action':'jy_weishop/store.manage.order/upprice/id='+item.id})"  class="btn btn-sm btn-red order-btn">修改价格</a>
                <a ng-click="post({},'jy_weishop/store.manage.order/print/','id='+item.id,'','确定要打印订单？')"  class="btn btn-sm btn-success order-btn">打印</a>
				<!-- 未付款 -->
                <a ng-if="item.ispay==0 && item.status<3" ng-click="post({},'jy_weishop/store.manage.order/ispay/','id='+item.id,'','确定改为已付款？')"  class="btn btn-sm btn-success order-btn">确定付款</a>
                <!-- 已付款 -->
				<a ng-if="item.status==1 && item.send_status==0" ng-click="access_json('jy_weishop/store.manage.order/fa/id='+item.id)" class="btn btn-success btn-sm order-btn" data-action="send">{{item.sendtype==1?'前往发货':'自提核销'}}</a>
                <a ng-if="item.status==2" ng-click="post({'id':item.id},'jy_weishop/store.manage.order/cancelfh/','','','确认取消订单发货吗？')" class="btn btn-success btn-sm order-btn" data-action="sendcancel">取消发货</a>
				<a ng-if="item.status==2" ng-click="post({},'jy_weishop/store.manage.order/shou/','id='+item.id)" class="btn btn-default btn-sm order-btn">确认收货</a>
                <a class="btn btn-default btn-sm" ng-click="access_json('jy_weishop/store.manage.order_detail//id='+item.id)">查看详情</a>
            </div>
        </div>
       <div class="content-empty" ng-show="pagedata.list.length == 0 ">
		  <i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">您暂时没有订单！</p>
		</div>
	</div>
    </div>
    <div class="head-menu-mask"></div>
</div>
<div ng-if="pagedata.op=='fa'" class='fui-page fui-page-current'>
    <div class="fui-header fui-header-success">
        <div class="fui-header-left">        
        </div>
        <div class="title">发货</div>
        <div class="fui-header-right"></div>
    </div>
    <div class='fui-content'>
        <div class="fui-cell-group">
            <div class="fui-cell ">
                <div class="fui-cell-label ">快递公司</div>
                <div class="fui-cell-info">
                    <select class="weui_select" name="select2" ng-model="pagedata.item.express">
                        <option ng-repeat="f in pagedata.express" value="{{f.id}}">{{f.name}}</option>
                    </select>
                <div class="fui-cell-remark"></div>
                </div>
            </div>
            <div class="fui-cell">
                <div class="fui-cell-label">快递单号</div>
                <div class="fui-cell-info">
                    <input type="text" placeholder="请输入快递单号" class="fui-input" ng-model="pagedata.item.expresssn"   id="subtitle" />
                </div>
            </div>
        </div>
		<div class="btn btn-success block" ng-click="post(pagedata.item,'jy_weishop/store.manage.order/postfa/')">确定</div>
	</div>
</div>
<div class="fui-navbar-tip" ng-if="pagedata.ids" style="height:2.5rem">
<div class="fui-cellone sm" style="padding:0">
	<div class="fui-cellone-info" style='line-height:1.4;font-size:0.7rem'>
		<span class="text">点击右侧“合并发货”，选中的订单统一发货！</span>
	</div>
	<div class="fui-cellone-remark noremark" style='line-height:1.4;font-size:0.7rem;'>
		<a ng-click="access_json('jy_weishop/store.manage.hefa//ids='+pagedata.ids);"  class="btn btn-sm btn-success order-btn" style="border-radius:1rem">合并发货</a>
	</div>
</div>
</div>
<div ng-include="sys_html('common/pluginnav',true)"></div>
<audio id="openvoice" controls preload="auto" style="display:none;">
	<source src="../core/resource/images/neworder.mp3"></source>
</audio>
<script type="text/javascript">
//手机软键盘--搜索
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});

scope.loading = true;
var page = 1;
var keyword = '';
var op = '';
op = scope.pagedata.op;
scope.tool.get_list('jy_weishop/store.manage.order/getlist/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_weishop/store.manage.order/getlist/');
}
scope.pagedata.openvoice=function(type){
	for(var i = 1;i<=100;i++){
		clearInterval(i);
	}
	var voicetime = 0;
    var openvoice;
	scope.post_json('jy_weishop/store.manage.index/openvoice/isopenvoice='+scope.pagedata.isopenvoice,{},function(res){
	});
	if(type==1){
		 openvoice = setInterval(() => {
			if(scope.pagedata.isopenvoice!=1 || scope.page.action!='store.manage.order'){
				clearInterval(openvoice);
				return false;
			}
			scope.get('jy_weishop/store.manage.order/getnew/storeid='+scope.pagedata.store.id,function(res){
				console.log('openvoice');
				if(res!='none'){
					voicetime ++;
					$("#openvoice")[0].play();
				}
			});
		}, 5000);
	}
}
if(scope.pagedata.isopenvoice==1){
	scope.pagedata.openvoice(1);
}
scope.pagedata.openLocation=function(item){
	var pcdaddress= item.pcd?item.pcd.province+item.pcd.city+item.pcd.district+item.pcd.street:'';
	var post={
		'address':pcdaddress+item.address,
		'city':item.pcd?item.pcd.city:''
	}
	scope.tool.get_latlng(post,function(res){
		var lat_lng = res.location
		var address_components = res.address_components
		wx.openLocation({
			latitude: lat_lng.lat, // 纬度，浮点数，范围为90 ~ -90
			longitude: lat_lng.lng, // 经度，浮点数，范围为180 ~ -180。
			name: pcdaddress, // 位置名
			address: item.address, // 地址详情说明
			scale: 20, // 地图缩放级别,整形值,范围从1~28。默认为最大
			infoUrl: '', // 在查看位置界面底部显示的超链接,可点击跳转
			success:function(){
				//alert(1111);
			},
			fail:function(res){
				scope.message('导航异常，可能是权限问题：'+res.errMsg);
			}
		});
	});
}
</script>
